// const { init, parse } = require('es-module-lexer'); // JS 模块语法解析器
// (async () => {
//   await init;
//   const [imports, exports] = parse(`import _ from 'lodash';\nexport var p = 5`);
//   console.log(imports); // [{ n: 'lodash', t: 1, s: 15, e: 21, ss: 0, se: 22, d: -1, a: -1 }]
//   console.log(exports); // [{ s: 35, e: 36, ls: 35, le: 36, n: 'p', ln: 'p' }];
// })();

const resolve = require('resolve'); // 实现了 node 的 require.resolve() 算法
const res = resolve.sync('resolve/package.json', { basedir: __dirname });
console.log(res); // D:\project\vite\vite-test\node_modules\resolve\index.js

// const fg = require('fast-glob'); // 匹配文件的库
// (async () => {
//   const entries = await fg(['test/**/*.js']);
//   console.log(entries); // [ 'test/index.js', 'test/test.js', 'test/public/index.js' ]
// })();

// const MagicString = require('magic-string'); // 操作字符串的库
// const ms = new MagicString('var age = 10');
// ms.overwrite(10, 12, '11');
// console.log(ms.toString()); // var age = 11
